`true_right_treat / false_right_treat` = true_right_treat / false_right_treat,
`true_left_treat / false_left_treat` = true_left_treat / false_left_treat,
`true_right_control - false_right_control` = true_right_control - false_right_control,
`true_left_control - false_left_control` = true_left_control - false_left_control,
`true_right_control / false_right_control` = true_right_control / false_right_control,
`true_left_control / false_left_control` = true_left_control / false_left_control) %>%
# treat minus control
transform(`diff_treatmenteffect_right` = `true_right_treat - false_right_treat` - `true_right_control - false_right_control`,
`ratio_treatmenteffect_right` = `true_right_treat / false_right_treat` / `true_right_control / false_right_control`,
`diff_treatmenteffect_left` = `true_left_treat - false_left_treat` - `true_left_control - false_left_control`,
`ratio_treatmenteffect_left` = `true_left_treat / false_left_treat` / `true_left_control / false_left_control`) %>%
# right minus left
transform(`diffleft_minus_diffright` = `diff_treatmenteffect_left` - `diff_treatmenteffect_right`,
`ratioleft_div_ratioright` = `ratio_treatmenteffect_left` / `ratio_treatmenteffect_right`,
`ratioleft_minus_ratioright` = `ratio_treatmenteffect_left` - `ratio_treatmenteffect_right`)
# Chunk 41
m6nc_treat_psa_data <-
long %>%
dplyr::select(share_01, hdl_true, party_dem, treat_psa, weight, caseid, hdl_id) %>%
filter(party_dem == 0) %>%
na.omit()
m6nc_treat_psa_all <-
glm(share_01 ~ hdl_true*treat_psa,
family = "gaussian", weights = weight, data = m6nc_treat_psa_data)
m6nc_treat_psa_true <-
glm(share_01 ~ treat_psa,
family = "gaussian", weights = weight, data = m6nc_treat_psa_data %>% filter(hdl_true == 1))
m6nc_treat_psa_false <-
glm(share_01 ~ treat_psa,
family = "gaussian", weights = weight, data = m6nc_treat_psa_data %>% filter(hdl_true == 0))
m6nc_treat_psa_sim <-
clarify::sim(m6nc_treat_psa_all, n = n_sim, vcov = xeffect.glm(glm.obj = m6nc_treat_psa_all, g1 = m6nc_treat_psa_all$data$caseid, g2 = m6nc_treat_psa_all$data$hdl_id))
m6nc_treat_psa_sim_apply <-
sim_apply(m6nc_treat_psa_sim, cl = 6,
function(fit){
true_right_treat <- predict(fit, newdata = m6nc_treat_psa_data %>% mutate(hdl_true = 1, treat_psa = 1), type = "response")
false_right_treat <- predict(fit, newdata = m6nc_treat_psa_data %>% mutate(hdl_true = 0, treat_psa = 1), type = "response")
true_right_control <- predict(fit, newdata = m6nc_treat_psa_data %>% mutate(hdl_true = 1, treat_psa = 0), type = "response")
false_right_control <- predict(fit, newdata = m6nc_treat_psa_data %>% mutate(hdl_true = 0, treat_psa = 0), type = "response")
c(true_right_treat = mean(true_right_treat),
false_right_treat = mean(false_right_treat),
true_right_control = mean(true_right_control),
false_right_control = mean(false_right_control))})
m6nc_treat_psa_transformed <-
transform(m6nc_treat_psa_sim_apply,
# true minus false
`true_right_treat - false_right_treat` = true_right_treat - false_right_treat,
`true_right_treat / false_right_treat` = true_right_treat / false_right_treat,
`true_right_control - false_right_control` = true_right_control - false_right_control,
`true_right_control / false_right_control` = true_right_control / false_right_control) %>%
# treat minus control
transform(`diff_treatmenteffect_right` = `true_right_treat - false_right_treat` - `true_right_control - false_right_control`,
`ratio_treatmenteffect_right` = `true_right_treat / false_right_treat` / `true_right_control / false_right_control`)
# Chunk 42
m7nc_treat_psa_data <-
long %>%
dplyr::select(share_01, hdl_true, party_dem, treat_psa, weight, caseid, hdl_id) %>%
filter(party_dem == 1) %>%
na.omit()
m7nc_treat_psa_all <-
glm(share_01 ~ hdl_true*treat_psa,
family = "gaussian", weights = weight, data = m7nc_treat_psa_data)
m7nc_treat_psa_true <-
glm(share_01 ~ treat_psa,
family = "gaussian", weights = weight, data = m7nc_treat_psa_data %>% filter(hdl_true == 1))
m7nc_treat_psa_false <-
glm(share_01 ~ treat_psa,
family = "gaussian", weights = weight, data = m7nc_treat_psa_data %>% filter(hdl_true == 0))
m7nc_treat_psa_sim <-
clarify::sim(m7nc_treat_psa_all, n = n_sim, vcov = xeffect.glm(glm.obj = m7nc_treat_psa_all, g1 = m7nc_treat_psa_all$data$caseid, g2 = m7nc_treat_psa_all$data$hdl_id))
m7nc_treat_psa_sim_apply <-
sim_apply(m7nc_treat_psa_sim, cl = 6,
function(fit){
true_left_treat <- predict(fit, newdata = m7nc_treat_psa_data %>% mutate(hdl_true = 1, treat_psa = 1), type = "response")
false_left_treat <- predict(fit, newdata = m7nc_treat_psa_data %>% mutate(hdl_true = 0, treat_psa = 1), type = "response")
true_left_control <- predict(fit, newdata = m7nc_treat_psa_data %>% mutate(hdl_true = 1, treat_psa = 0), type = "response")
false_left_control <- predict(fit, newdata = m7nc_treat_psa_data %>% mutate(hdl_true = 0, treat_psa = 0), type = "response")
c(true_left_treat = mean(true_left_treat),
false_left_treat = mean(false_left_treat),
true_left_control = mean(true_left_control),
false_left_control = mean(false_left_control))})
m7nc_treat_psa_transformed <-
transform(m7nc_treat_psa_sim_apply,
# true minus false
`true_left_treat - false_left_treat` = true_left_treat - false_left_treat,
`true_left_treat / false_left_treat` = true_left_treat / false_left_treat,
`true_left_control - false_left_control` = true_left_control - false_left_control,
`true_left_control / false_left_control` = true_left_control / false_left_control) %>%
# treat minus control
transform(`diff_treatmenteffect_left` = `true_left_treat - false_left_treat` - `true_left_control - false_left_control`,
`ratio_treatmenteffect_left` = `true_left_treat / false_left_treat` / `true_left_control / false_left_control`)
# Chunk 43
# Dem and Rep
fig5_dem_rep_byinterventiontype <-
rbind(
# pooled
summary(m6nc_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_right") %>%
mutate(respondent_party = "Republicans", intervention = "Pooled"),
summary(m7nc_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_left") %>%
mutate(respondent_party = "Democrats", intervention = "Pooled"),
# accuracy
summary(m6nc_treat_accuracy_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_right") %>%
mutate(respondent_party = "Republicans", intervention = "Accuracy"),
summary(m7nc_treat_accuracy_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_left") %>%
mutate(respondent_party = "Democrats", intervention = "Accuracy"),
# headline
summary(m6nc_treat_headline_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_right") %>%
mutate(respondent_party = "Republicans", intervention = "Headline"),
summary(m7nc_treat_headline_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_left") %>%
mutate(respondent_party = "Democrats", intervention = "Headline"),
# headline w/ feedback
summary(m6nc_treat_headlineFeedback_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_right") %>%
mutate(respondent_party = "Republicans", intervention = "Headline w/ Feedback"),
summary(m7nc_treat_headlineFeedback_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_left") %>%
mutate(respondent_party = "Democrats", intervention = "Headline w/ Feedback"),
# psa
summary(m6nc_treat_psa_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_right") %>%
mutate(respondent_party = "Republicans", intervention = "PSA"),
summary(m7nc_treat_psa_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratio_treatmenteffect_left") %>%
mutate(respondent_party = "Democrats", intervention = "PSA")) %>%
mutate(intervention = factor(intervention, levels = c("Pooled", "Accuracy", "Headline", "Headline w/ Feedback", "PSA"))) %>%
ggplot(aes(x = respondent_party,
y = Estimate,
ymin = `2.5 %`,
ymax = `97.5 %`,
shape = intervention)) +
geom_hline(yintercept = 1) +
geom_pointrange(position = position_dodge(.4)) +
# scale_color_manual(breaks = c("Democratic", "Republican"),
#                    values = c(cb_blue, cb_red))   +
theme_bw() +
theme(legend.position = "bottom") +
xlab("") +
ylim(c(.6, 1.65)) +
ylab("Treattment Effect on Discernment") +
scale_shape_manual(breaks = c("Pooled", "Accuracy", "Headline", "Headline w/ Feedback", "PSA"),
values = c(15, 1, 0, 2, 5),
name = "Intervention Type:")
# Dem vs. Rep Difference
fig5_dem_vs_rep_byinterventiontype <-
rbind(
# pooled
summary(m5nc_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratioleft_div_ratioright") %>%
mutate(respondent_party = "All", intervention = "Pooled"),
# accuracy
summary(m5nc_treat_accuracy_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratioleft_div_ratioright") %>%
mutate(respondent_party = "All", intervention = "Importance + Norms"),
# headline
summary(m5nc_treat_headline_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratioleft_div_ratioright") %>%
mutate(respondent_party = "All", intervention = "Evaluation"),
# headline w/ feedback
summary(m5nc_treat_headlineFeedback_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratioleft_div_ratioright") %>%
mutate(respondent_party = "All", intervention = "Evaluation w/ Feedback"),
# psa
summary(m5nc_treat_psa_transformed) %>%
as.data.frame() %>%
rownames_to_column("quantity") %>%
filter(quantity == "ratioleft_div_ratioright") %>%
mutate(respondent_party = "All", intervention = "PSA")) %>%
mutate(quantity = ifelse(quantity == "ratioleft_div_ratioright", "Treatment Effect on Discernment: Democrat / Republican", NA)) %>%
mutate(intervention = factor(intervention, levels = c("Pooled", "Importance + Norms", "Evaluation", "Evaluation w/ Feedback", "PSA"))) %>%
ggplot(aes(x = quantity,
y = Estimate,
ymin = `2.5 %`,
ymax = `97.5 %`,
shape = intervention)) +
geom_hline(yintercept = 1) +
geom_pointrange(position = position_dodge(.4)) +
theme_bw() +
theme(legend.position = "bottom") +
xlab("") +
ylim(c(.6, 1.65)) +
scale_shape_manual(breaks = c("Pooled", "Importance + Norms", "Evaluation", "Evaluation w/ Feedback", "PSA"),
values = c(15, 1, 0, 2, 5),
name = "Intervention Type:")
ggsave(
fig5_dem_rep_byinterventiontype +  fig5_dem_vs_rep_byinterventiontype + plot_annotation(tag_levels = 'A') +  plot_layout(guides = "collect") & theme(legend.position = "bottom") ,
width = 9, height = 4, filename = here("figures", "main", "fig6.pdf"))
# Chunk 45
# Figure 5 p values
summary(m6nc_transformed, parm = "ratio_treatmenteffect_right", null = 1)
summary(m7nc_transformed, parm = "ratio_treatmenteffect_left", null = 1)
summary(m5nc_transformed, parm = "ratio_treatmenteffect_left", null = 1)
summary(m5nc_transformed, parm = "ratioleft_div_ratioright", null = 1)
# Chunk 1: setup
knitr::opts_chunk$set(echo = TRUE)
# Chunk 2
# clearing memory ------------------------------------------------------------
rm(list = ls())
# load packages ----------------------------------------------------------------
library(here)
library(tidyverse)
library(ggplot2)
library(survey)
library(srvyr)
library(ggeffects)
library(stargazer)
library(broom)
library(ggstance)
library(ggpubr)
library(arm)
library(gridExtra)
library(doParallel)
library(foreach)
library(broom)
library(margins)
library(patchwork)
library(relimp, pos = 4)
library(paran)
library(clarify)
library(viridis)
library(stringr)
# useful functions -------------------------------------------------------------
# function to calculate standard error of mean
std_error <- function(var){
sd(var, na.rm = T) / sqrt(length(var[!is.na(var)]))
}
# function to manually bin continous variables
bin_fun <- function(x, bin_size){
bin_size * ceiling(x / bin_size) - bin_size / 2
}
# function to put variables on a 0-1 scale
rescale_01 <- function(x, max){
(x-1)/(max-1)
}
# function to compute two-way clustered standard errors with survey weights
source(here("code", "helper functions", "glmweave.R"))
# set n_sim
n_sim <- 10000 # higher n_sim to get more precise p values
# set seed
set.seed(4787)
# plotting colors
cb_black <- "#000000" # Discernment / all headlines
cb_blue <- "#0072B2"  # Democratic headlines
cb_red<- "#D55E00"    # Republican headlines
cb_green = "#009E73"  # True headlines
cb_orange = "#E69F00" # False headlines
# Chunk 3
# mturk pre-test survey data (MTurk sample)
mturk <- read.csv(here("data", "pretest", "Feb_2020_Pretest_New_Stimuli_W20_MTurk.csv"))
# key that matches different headline IDs together
key <- read_xlsx(here("data", "pretest", "feb_20_qualtrics_ids.xlsx"))
# yougov's key that matches different headline IDs together
request <- read.csv(here("data", "pretest", "guay_data_request_2024.csv"))
# Chunk 4
# rename variables
names(mturk) <- str_replace(names(mturk), "f_fav", "partisan")
names(mturk) <- str_replace(names(mturk), "f_true", "true")
# create vectors of variable names
partisan_vars <- colnames(mturk)[str_detect(colnames(mturk), "partisan")]
true_vars <- colnames(mturk)[str_detect(colnames(mturk), "true")]
# rater party
mturk$respondent_party_bg <- ifelse(mturk$DemRep_C < 4, "dem", "rep")
# clean mturk data
mturk_cleaned <-
mturk %>%
# only include respondents who passed the two attention checks
filter(Random != 1,
Google != 1) %>%
dplyr::select(
caseid = V1,
party = respondent_party_bg,
all_of(true_vars),
all_of(partisan_vars)
) %>%
gather(key, rating, -caseid, -party) %>%
separate(key, into = c("characteristic", "hdl_number"), sep = "_")
# merge 'file name' from key into mturk_cleaned ---------------------------------
mturk_cleaned_2 <-
merge(mturk_cleaned,
key %>% dplyr::select(file_name = headline, hdl_number = `Item#`),
by = "hdl_number")
dim(mturk_cleaned)
dim(mturk_cleaned_2)
# merge yougov hdl_id from request into mturk_cleaned -------------------------------
mturk_cleaned_3 <-
merge(mturk_cleaned_2,
request %>% dplyr::select(hdl_id = varname, file_name) %>%
mutate(file_name_tmp = str_replace(file_name, " f_", "f_")) %>%
mutate(file_name = str_replace(file_name_tmp, " r_", "r_"))) %>%
dplyr::select(-file_name_tmp) %>%
mutate(rating_01 = rescale_01(rating, max = 6)) %>%
mutate(hdl_true = ifelse(str_detect(hdl_id, "REAL"), 1, 0),
hdl_party = ifelse(str_detect(hdl_id, "DEM"), "dem", "rep")) %>%
mutate(hdl_agreeable = ifelse(hdl_party == party, 1, 0))
dim(mturk_cleaned_2)
dim(mturk_cleaned_3)
# verify that the mturk data matches the excel sheet containing summary stats used elsewhere in the project --------
# import edited summary sheet
summary_sheet <- read_xlsx(here("data",
"pretest",
"Pretest6 results_bg_edited.xlsx"))
# format table from summary sheet
summary_tbl_final <-
summary_sheet %>%
dplyr::select(file_name = Headline,
partisan_demrater = partisan_dem_rater,
partisan_reprater = partisan_rep_rater,
true_demrater = true_dem,
true_reprater = true_rep) %>%
gather(key, summary_mean, -file_name) %>%
separate(key, into = c("characteristic", "party")) %>%
mutate(party = str_remove(party, "rater"))
# make mturk data comparable to summary_tbl
mturk_tbl_final <-
mturk_cleaned_3%>%
mutate(hdl_true = ifelse(str_detect(hdl_id, "REAL"), 1, 0),
hdl_party = ifelse(str_detect(hdl_id, "DEM"), "dem",
ifelse(str_detect(hdl_id, "REP"), "rep", NA))) %>%
group_by(file_name, characteristic, party) %>%
summarize(mturk_mean = mean(rating, na.rm=T)) %>%
na.omit()
merged <-
merge(mturk_tbl_final, summary_tbl_final, by = c("file_name", "characteristic", "party"))
dim(mturk_tbl_final)
dim(summary_tbl_final)
dim(merged)
# vector of 'file_names' (headline image file names) used in YouGov survey
file_name_used_0 <- str_remove(unique(request$file_name), " ")
file_name_used <- file_name_used_0[!str_detect(file_name_used_0, "c_")]
merged_short <- merged[merged$file_name %in% file_name_used,]
dim(merged_short)
# excel sheet containing summary stats matches raw Qualtrics data -------------------------------
with(merged_short, cor(mturk_mean, summary_mean, use = "complete.obs"))
# Chunk 5
fig_accuracy_agreeable <-
mturk_cleaned_3 %>%
filter(characteristic == "true") %>%
group_by(party, hdl_true, hdl_agreeable) %>%
summarize(mean = mean(rating_01, na.rm=T),
se = std_error(rating_01)) %>%
mutate(hdl_true = ifelse(hdl_true == 1, "True", "False")) %>%
filter(hdl_agreeable == 1) %>%
ggplot(aes(x = factor(hdl_true),
y = mean,
ymin = mean - 1.96*se,
ymax = mean + 1.96*se,
label = round(mean, 2),
fill = factor(party))) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(size = .3, width = .2) +
geom_text(aes(y = mean + 1.96*se),
nudge_y = .02, size = 3) +
facet_wrap(vars(party)) +
theme_bw() +
scale_fill_manual(breaks = c("dem", "rep"),
labels = c("Democrats", "Republicans"),
values = c(cb_blue, cb_red),
name = "") +
xlab("Headline Veracity") +
ylab("Mean Accuracy Rating (0-1)") +
ggtitle("Agreeable Headlines") +
theme(legend.position = "none") +
xlab("") +
ylim(c(0, .65))
fig_accuracy_disagreeable <-
mturk_cleaned_3 %>%
filter(characteristic == "true") %>%
group_by(party, hdl_true, hdl_agreeable) %>%
summarize(mean = mean(rating_01, na.rm=T),
se = std_error(rating_01)) %>%
mutate(hdl_true = ifelse(hdl_true == 1, "True", "False")) %>%
filter(hdl_agreeable == 0) %>%
ggplot(aes(x = factor(hdl_true),
y = mean,
ymin = mean - 1.96*se,
ymax = mean + 1.96*se,
label = round(mean, 2),
fill = factor(party))) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(size = .3, width = .2) +
geom_text(aes(y = mean + 1.96*se),
nudge_y = .02, size = 3) +
facet_wrap(vars(party)) +
theme_bw() +
scale_fill_manual(breaks = c("dem", "rep"),
labels = c("Democrats", "Republicans"),
values = c(cb_blue, cb_red),
name = "") +
xlab("Headline Veracity") +
ylab("Mean Accuracy Rating (0-1)") +
ggtitle("Disagreeable Headlines") +
theme(legend.position = "none") +
xlab("") +
ylim(c(0, .65))
ggsave(fig_accuracy_agreeable + fig_accuracy_disagreeable +
plot_annotation(tag_levels = 'A'),
width = 8, height = 4, filename = here("figures", "main", "fig_accuracy.pdf"))
# Chunk 6
# test whether differences in figure are statistically significant ---------------------------------
mturk_cleaned_3$party_dem <- ifelse(mturk_cleaned_3$party == "dem", 1, 0)
## Agreeable Headlines (m2nc)
m2_data <-
mturk_cleaned_3 %>%
filter(characteristic == "true") %>%
dplyr::select(caseid, party_dem, hdl_id,
rating_01, hdl_true, hdl_agreeable) %>%
filter(hdl_agreeable == 1) %>%
na.omit()
m2_all <-
glm(rating_01 ~ hdl_true*party_dem,
family = "gaussian", data = m2_data)
m2_true <-
glm(rating_01 ~ party_dem,
family = "gaussian", data = m2_data %>% filter(hdl_true == 1))
m2_false <-
glm(rating_01 ~ party_dem,
family = "gaussian", data = m2_data %>% filter(hdl_true == 0))
m2_sim <-
clarify::sim(m2_all, n = n_sim, vcov = xeffect.glm(glm.obj = m2_all, g1 = m2_all$data$caseid, g2 = m2_all$data$hdl_id))
m2_sim_apply <-
sim_apply(m2_sim, cl = 6,
function(fit){
true_right <- predict(fit, newdata = m2_data %>% mutate(hdl_true = 1, party_dem = 0), type = "response")
true_left <- predict(fit, newdata = m2_data %>% mutate(hdl_true = 1, party_dem = 1), type = "response")
false_right <- predict(fit, newdata = m2_data %>% mutate(hdl_true = 0, party_dem = 0), type = "response")
false_left <- predict(fit, newdata = m2_data %>% mutate(hdl_true = 0, party_dem = 1), type = "response")
c(true_right = mean(true_right), true_left = mean(true_left),
false_right = mean(false_right), false_left = mean(false_left))})
m2_transformed <-
transform(m2_sim_apply,
#  `true_right - false_right` = true_right - false_right,
#  `true_left - false_left` = true_left - false_left,
`true_right / false_right` = true_right / false_right,
`true_left / false_left` = true_left / false_left) %>%
transform(#`diff` = `true_left - false_left` - `true_right - false_right` ,
`ratio` = `true_left / false_left` / `true_right / false_right`)
## Disagreeable Headlines (m3nc)
m3_data <-
mturk_cleaned_3 %>%
filter(characteristic == "true") %>%
dplyr::select(caseid, party_dem, hdl_id,
rating_01, hdl_true, hdl_agreeable) %>%
filter(hdl_agreeable == 0) %>%
na.omit()
m3_all <-
glm(rating_01 ~ hdl_true*party_dem,
family = "gaussian", data = m3_data)
m3_true <-
glm(rating_01 ~ party_dem,
family = "gaussian", data = m3_data %>% filter(hdl_true == 1))
m3_false <-
glm(rating_01 ~ party_dem,
family = "gaussian", data = m3_data %>% filter(hdl_true == 0))
m3_sim <-
clarify::sim(m3_all, n = n_sim, vcov = xeffect.glm(glm.obj = m3_all, g1 = m3_all$data$caseid, g2 = m3_all$data$hdl_id))
m3_sim_apply <-
sim_apply(m3_sim, cl = 6,
function(fit){
true_right <- predict(fit, newdata = m3_data %>% mutate(hdl_true = 1, party_dem = 0), type = "response")
true_left <- predict(fit, newdata = m3_data %>% mutate(hdl_true = 1, party_dem = 1), type = "response")
false_right <- predict(fit, newdata = m3_data %>% mutate(hdl_true = 0, party_dem = 0), type = "response")
false_left <- predict(fit, newdata = m3_data %>% mutate(hdl_true = 0, party_dem = 1), type = "response")
c(true_right = mean(true_right), true_left = mean(true_left),
false_right = mean(false_right), false_left = mean(false_left))})
m3_transformed <-
transform(m3_sim_apply,
`true_right - false_right` = true_right - false_right,
`true_left - false_left` = true_left - false_left,
`true_right / false_right` = true_right / false_right,
`true_left / false_left` = true_left / false_left) %>%
transform(`diff` = `true_left - false_left` - `true_right - false_right` ,
`ratio` = `true_left / false_left` / `true_right / false_right`)
# results -----------------------------------------------------------------------------------------
# agreeable
summary(m2_transformed) %>% tail(7)
summary(m2_transformed, parm = "ratio", null = 1)
# disagreeeable
summary(m3_transformed) %>% tail(14)
summary(m3_transformed, parm = "ratio", null = 1)
